home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: clamage@Eng.sun.com (Steve Clamage)
- Newsgroups: comp.std.c++
- Subject: Re: Quick questions
- Date: 26 Mar 1996 19:13:13 GMT
- Organization: Sun Microsystems Inc.
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4j9f6i$s2o@engnews1.Eng.Sun.COM>
- References: <315837ce.67891262@sqarc.sq.com>
- Reply-To: clamage@Eng.sun.com
- NNTP-Posting-Host: taumet.eng.sun.com
- X-Nntp-Posting-Host: taumet.eng.sun.com
- Content-Length: 1026
- X-Lines: 31
- Originator: clamage@taumet
-
- In article 67891262@sqarc.sq.com, clamage@taumet.eng.sun.com (Steve Clamage) writes:
- >clamage@Eng.sun.com (Steve Clamage) wrote:
-
- >>>2) From a previous post on this group, it looks like the standard will
- >>>allow one to define conversion operators for pre-existing, source code
- >>>untouchable data types. Yes? No? What will this look like? I have the
- >>>May copy of the WP, and don't see any mention of this.
- >>
- >>I'm not sure I understand what you are asking. If you mean can you define
- >>a conversion operator from a user-defined class to a predefined type
- >>like int or double, then yes, that has long been part of C++.
-
- >I believe he was referring to something like
-
- >class myclass{};
- >operator int(const myclass &arg);
- >
- >Just like the global equality operators, etc.
-
- That is not allowed. A type conversion function must be a member of a class.
-
- class myclass {
- public:
- operator int(); // converts a myclass to an int
- myclass(int); // converts an int to a myclass
- };
-
- ---
- Steve Clamage, stephen.clamage@eng.sun.com
-
-
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-